

import ComponentBase from "../../engine/ComponentBase";
import { Logger } from "../../engine/Logger";
import { GameConfig } from "../config/GameConfig";
import { RoomConfig } from "../config/RoomConfig";
import { RoomConfig_cangxian_mj } from "../config/RoomConfig_cangxian_mj";
import { RoomConfig_dazhonger_mj } from "../config/RoomConfig_dazhonger_mj";
import { RoomConfig_ddz } from "../config/RoomConfig_ddz";
import { RoomConfig_huanghua_mj } from "../config/RoomConfig_huanghua_mj";
import { RoomConfig_jianziding } from "../config/RoomConfig_jianziding";
import { RoomConfig_paodekuai } from "../config/RoomConfig_paodekuai";
import { RoomModel } from "../model/RoomModel";
import { UIHelper } from "../util/UIHelper";

const { ccclass, property } = cc._decorator;

@ccclass
export default class ViewGameRule extends ComponentBase {

    private roomObj: object;

    public onInitChild(roomObj: object) {
        this.roomObj = roomObj;
        Logger.log("ViewGameRule==", roomObj)
        this.refresh()
    }

    onEnable(): void {
        super.onEnable();
        UIHelper.onAddEvent(this.node, () => {
            this.node.active = false
        }, cc.Button.Transition.NONE)
    }

    private refresh() {
        let confObj: object = this.roomObj["conf"]
        let txtGameInfo: cc.Label = this.getChild(this.node, "txtGameInfo", cc.Label)
        txtGameInfo.string = "仁怀麻将," + confObj["jushu"] + "局," + confObj["renshu"] + "人麻将"
        txtGameInfo.string += "," + RoomConfig_huanghua_mj.jiTypeNameConfig[confObj["jiType"]]
        if (confObj["benbenji"] == 1) {
            txtGameInfo.string += ",本本鸡"
        }
        if (confObj["jinyinwu"] == 1) {
            txtGameInfo.string += ",金银乌"
        }
        if (confObj["jianqiwa"]) {
            txtGameInfo.string += ",见七挖"
        }
        if (confObj["zhuangcheng"]) {
            txtGameInfo.string += ",庄上必乘"
        }
        if (confObj["ruanyingji"]) {
            txtGameInfo.string += ",软硬鸡"
        }
        if (confObj["ruanyingdou"]) {
            txtGameInfo.string += ",软硬豆"
        }
        txtGameInfo.string += ",见豆" + RoomConfig_huanghua_mj.jiandouConfig[confObj["jiandou"]]
        txtGameInfo.string += ",大宽张" + RoomConfig_huanghua_mj.dakuanzhangConfig[confObj["dakuanzhang"]] + "+"
        txtGameInfo.string += ",大对子" + RoomConfig_huanghua_mj.daduiziConfig[confObj["daduizi"]] + "+"
        txtGameInfo.string += ",清一色" + RoomConfig_huanghua_mj.qingGangConfig[confObj["qinggang"]] + "+"
        txtGameInfo.string += ",自摸" + RoomConfig_huanghua_mj.zimoConfig[confObj["zimo"]] + "+"

    }
}
